/**
 * Copyright 2011 the original author or authors
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package it.av.spring.security.page;

import it.av.spring.security.SecurityContextHelper;
import it.av.spring.security.UserDetailsImpl;

import org.apache.wicket.authorization.strategies.role.Roles;
import org.apache.wicket.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.markup.html.CSSPackageResource;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.resources.CompressedResourceReference;

/**
 * Page Protected using Wicket Security Annotation
 * 
 * @author <a href='mailto:a.vincelli@gmail.com'>Alessandro Vincelli</a>
 */
@AuthorizeInstantiation(value={Roles.USER})
public class ProtectedPage extends WebPage {

    private static final CompressedResourceReference STYLES_JQUERY_CSS = new CompressedResourceReference(ProtectedPage.class,
            "resources/jquery.css");

    /**
     * Constructor
     */
    public ProtectedPage() {

        add(CSSPackageResource.getHeaderContribution(STYLES_JQUERY_CSS));
        UserDetailsImpl authenticatedUser = SecurityContextHelper.getAuthenticatedUser();
        
        
        add(new Label("firstName", authenticatedUser.getFirstName()));
        add(new Label("lastName", authenticatedUser.getLastName()));
        
        add(new BookmarkablePageLink<String>("homePage", HomePage.class));
            
    }

}